<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>ctags</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_001_014_263">&nbsp;</a>NAME</h4><blockquote>
ctags - create a tags file (<b>DEVELOPMENT</b>, <b>FORTRAN</b>)
</blockquote><h4><a name = "tag_001_014_264">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

ctags <b>[</b>-a<b>][</b>-f <i>tagsfile</i><b>] </b><i>pathname</i> ...

ctags -x <i>pathname</i> ...
</code>
</pre>
</blockquote><h4><a name = "tag_001_014_265">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>ctags</i>
utility creates a
<i>tags</i>
file or an index of objects
from C-language or FORTRAN source files specified by the
<i>pathname</i>
operands.
(FORTRAN source is processed only on systems supporting the
FORTRAN option.)
The tags file lists the
locators of language-specific objects
within the source files.
A locator consists of a name,
pathname and either basic regular expression
or a line number
that can be used in searching for the object definition.
The objects that will be recognised are specified in the
EXTENDED DESCRIPTION section.
</blockquote><h4><a name = "tag_001_014_266">&nbsp;</a>OPTIONS</h4><blockquote>
The
<i>ctags</i>
utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b>&nbsp;</a> .
<p>
The following options are supported:
<dl compact>

<dt><b>-a</b>
<dd>Append to tags file.

<dt><b>-f&nbsp;</b><i>tagsfile</i>
<dd>
Write the object locator lists into
<i>tagsfile</i>
instead of the default file named
<b>tags</b>
in the current directory.

<dt><b>-x</b>
<dd>Produce a list of object names, the line number and filename
in which each is defined, as well as the text of that line,
and write this to the standard output.
A
<b>tags</b>
file is not created when
<b>-x</b>
is specified.

</dl>
</blockquote><h4><a name = "tag_001_014_267">&nbsp;</a>OPERANDS</h4><blockquote>
The following
<i>pathname</i>
operands are supported:
<dl compact>

<dt><i>file</i><b>.c</b><dd>Files with basenames ending with the
<b>.c</b>
suffix are treated as C-language source code.
Such files that are not valid input to
<i><a href="c89.html">c89</a></i>
produce unspecified results.

<dt><i>file</i><b>.h</b><dd>Files with basenames ending with the
<b>.h</b>
suffix are treated as C-language source code.
Such files that are not valid input to
<i><a href="c89.html">c89</a></i>
produce unspecified results.

<dt><i>file</i><b>.f</b><dd>Files with basenames ending with the
<b>.f</b>
suffix are treated as FORTRAN-language source code.
Such files that are not valid input to
<i><a href="fort77.html">fort77</a></i>
produce unspecified results.

</dl>
<p>
The handling of other files is implementation-dependent.
</blockquote><h4><a name = "tag_001_014_268">&nbsp;</a>STDIN</h4><blockquote>
See the INPUT FILES section.
</blockquote><h4><a name = "tag_001_014_269">&nbsp;</a>INPUT FILES</h4><blockquote>
The input files must be text files
containing source code in the language indicated by the
operand filename suffixes.
</blockquote><h4><a name = "tag_001_014_270">&nbsp;</a>ENVIRONMENT VARIABLES</h4><blockquote>
The following environment variables affect the execution of
<i>ctags</i>:
<dl compact>

<dt><i>LANG</i><dd>Provide a default value for the internationalisation variables
that are unset or null.
If
<i>LANG</i>
is unset or null, the corresponding value from the
implementation-dependent default locale will be used.
If any of the internationalisation variables contains
an invalid setting, the
utility will behave as if none of the variables had been defined.

<dt><i>LC_ALL</i><dd>
If set to a non-empty string value,
override the values of all the other internationalisation variables.

<dt><i>LC_COLLATE</i><dd>
Determine the
order in which output is sorted
for the
<b>-x</b>
option.
The POSIX locale determines
the order in which the tags file is written.

<dt><i>LC_CTYPE</i><dd>
Determine the
locale for the interpretation of sequences of bytes of text data as
characters (for example, single- as opposed to multi-byte characters
in arguments and input files).
When processing C-language source code,
if the locale is not compatible with the
C locale described by the ISO&nbsp;C standard,
the results are unspecified.

<dt><i>LC_MESSAGES</i><dd>
Determine the locale that should be used to affect
the format and contents of diagnostic
messages written to standard error.

<dt><i>NLSPATH</i><dd>
Determine the location of message catalogues
for the processing of
<i>LC_MESSAGES .
</i>
</dl>
</blockquote><h4><a name = "tag_001_014_271">&nbsp;</a>ASYNCHRONOUS EVENTS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_001_014_272">&nbsp;</a>STDOUT</h4><blockquote>
The list of object name information produced by the
<b>-x</b>
option is written to standard output
in the following format:
<p><code>
<pre>
<tt>"%s %d %s %s"</tt>, &lt;<i>object-name</i>&gt;,
&lt;<i>line-number</i>&gt;,
&lt;<i>filename</i>&gt;,
&lt;<i>text</i>&gt;
<br>
</pre>
</code>
where
&lt;<i>text</i>&gt;
is the text of line
&lt;<i>line-number</i>&gt;
of file
&lt;<i>filename</i>&gt;.
</blockquote><h4><a name = "tag_001_014_273">&nbsp;</a>STDERR</h4><blockquote>
Used only for diagnostic messages.
</blockquote><h4><a name = "tag_001_014_274">&nbsp;</a>OUTPUT FILES</h4><blockquote>
When the
<b>-x</b>
option is not specified, the format of the output file is:
<p><code>
<tt>"%s\t%s\t/%s/\n"</tt>, &lt;<i>identifier</i>&gt;,
&lt;<i>filename</i>&gt;,
&lt;<i>rexp</i>&gt;
</code>
where
&lt;<i>rexp</i>&gt;
is a basic regular expression
(see
the <b>XBD</b> specification, <a href="../xbd/re.html#tag_007_003"><b>Basic Regular Expressions</b>&nbsp;</a> )
that could be used by an editor to find
the defining instance of
&lt;<i>identifier</i>&gt;
in
&lt;<i>filename</i>&gt;
(where &quot;defining instance&quot; is indicated by the declarations listed in
the EXTENDED DESCRIPTION section).
<p>
An alternative format is:
<p><code>
<tt>"%s\t%s\t%d\n"</tt>, &lt;<i>identifier</i>&gt;,
&lt;<i>filename</i>&gt;,
&lt;<i>lineno</i>&gt;
</code>
where
&lt;<i>lineno</i>&gt;
is a decimal line number
that could be used by an editor to find
&lt;<i>identifier</i>&gt;
in
&lt;<i>filename</i>&gt;.
This alternative format is not produced by
<i>ctags</i>
when it is used as described by this specification,
but the standard utilities that process tags files
are able to process this format as well
as the preceding one.
<p>
In either format, the file will be sorted by identifier, based on the
collation sequence in the POSIX locale.
<br>
</blockquote><h4><a name = "tag_001_014_275">&nbsp;</a>EXTENDED DESCRIPTION</h4><blockquote>
If the operand identifies C-language source, the
<i>ctags</i>
utility will attempt to produce an output line
for each of the following objects:
<ul>
<p>
<li>
function definitions
<p>
<li>
type definitions
<p>
<li>
macros with arguments.
<p>
</ul>
<p>
It may also produce output for any of the following objects:
<ul>
<p>
<li>
function prototypes
<p>
<li>
structures
<p>
<li>
unions
<p>
<li>
global variable definitions
<p>
<li>
enumeration types
<p>
<li>
macros without arguments
<p>
<li>
<b>#define</b>
statements
<p>
<li>
<b>#line</b>
statements.
<p>
</ul>
<p>
Any
<b>#if</b>
and
<b>#ifdef</b>
statements will produce no output.
The tag
<b>main</b>
is treated specially in C programs.
The tag formed
is created by prefixing
<b>M</b>
to the name of the file, with the trailing
<b>.c</b>,
and leading pathname components (if any) removed.
This special treatment of
<b>main</b>
makes the use of
<i>ctags</i>
practical in directories with more than one program.
<p>
If the operand identifies FORTRAN source, the
<i>ctags</i>
utility will produce an output line for each
function definition.
It may also produce output for any of the following objects:
<ul>
<p>
<li>
subroutine definitions
<p>
<li>
COMMON statements
<p>
<li>
PARAMETER statements
<p>
<li>
DATA and BLOCK DATA statements
<p>
<li>
statement numbers.
<p>
</ul>
<p>
On systems that do not support the FORTRAN option,
<i>ctags</i>
produces unspecified results for FORTRAN source code files.
It writes to standard error a message identifying this condition
and causes a non-zero exit status to be produced.
<p>
It is implementation-dependent
what other objects (including duplicate identifiers)
produce output.
</blockquote><h4><a name = "tag_001_014_276">&nbsp;</a>EXIT STATUS</h4><blockquote>
The following exit values are returned:
<dl compact>

<dt>0<dd>Successful completion.

<dt>&gt;0<dd>An error occurred.

</dl>
</blockquote><h4><a name = "tag_001_014_277">&nbsp;</a>CONSEQUENCES OF ERRORS</h4><blockquote>
Default.
<br>
</blockquote><h4><a name = "tag_001_014_278">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
The output with
<b>-x</b>
is meant to be a simple index
that can be written out as an off-line readable function index.
If the input files to
<i>ctags</i>
(such as
<b>.c</b>
files) were not created using
the same locales as those in effect when
<i>ctags</i>
<b>-x</b>
is run,
results might not be as expected.
<p>
The description of C-language processing says &quot;will attempt to&quot;
because the C language can be greatly confused, especially
through the use of
<b>#defines</b>,
and this utility would be of
no use if the real C preprocessor were run to identify them.
The output from
<i>ctags</i>
may be fooled and incorrect for various constructs.
</blockquote><h4><a name = "tag_001_014_279">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_280">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
The IEEE PASC 1003.2 Interpretations Committee has forwarded concerns about 
parts of this interface definition to the IEEE PASC Shell and Utilities Working Group
which is identifying the corrections.
A future revision of this specification will align with
IEEE Std. 1003.2b when finalised.
</blockquote><h4><a name = "tag_001_014_281">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="c89.html">c89</a></i>,
<i><a href="fort77.html">fort77</a></i>,
<i><a href="vi.html">vi</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
